package com.webserver.http;

import java.io.IOException;
import java.security.PrivateKey;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class HttpContext {
    //回车符
    public static final char CR = 13;
    //换行符
    public static final char LF = 10;

    private static Map<String, String> mimeMapping = new HashMap<>();

    static {
        initMimeMapping();
    }

    private static void initMimeMapping() {
        try {
            //java.io.Properties 该类用于读取并表示.properties文件内容
            Properties properties = new Properties();

            properties.load(
                    HttpContext.class.getResourceAsStream("web.properties")
            );
            properties.forEach((k,v)->mimeMapping.put(k.toString(),v.toString()));
            System.out.println(properties.size());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getMimeType(String ext) {
        return mimeMapping.get(ext);
    }
}